import React, { useEffect, useState } from 'react';
import { Modal, Form, Space } from 'antd';
import FormCondition from '@/components/FormCondition';
import { connect, history } from 'umi';
import { Button, Row, Col } from 'antd';
import aliOssUpload from '@/utils/aliOssUpload';
const editModal = (props) => {
    const { visible = false, onClose, loading, dispatch, handleCallback, } = props;
    const { show = false, detail = {} } = visible;
    const { id } = detail;
    const [form] = Form.useForm();
    // 确认提交
    const acceptData = 'image/*,video/*'
    const handleUpAudit = () => {
        form.validateFields().then(async (values) => {
            const { content, img } = values
            const list = await aliOssUpload(img)
            dispatch({
                type: 'answering/fakeChatUserQa',
                payload: {
                    content: JSON.stringify({
                        contentType: 'mix',
                        text: content,
                        images: list.toString()
                    }),
                    userQaId: id
                },
                callback: () => {
                    onClose()
                }
            })
        });
    };
    const formItems = [

        {
            label: '回复描述',
            name: 'content',
            type: 'textArea'
        },
        {
            label: '回复图片',
            name: 'img',
            accept: acceptData,
            maxFile: 9,
            type: 'otherUpload',
            rules: [{ required: false }],
        },
    ];

    const modalProps = {
        title: '回复',
        width: 800,
        visible: show,
        maskClosable: true,
        destroyOnClose: true,
        zIndex: 1001,
        confirmLoading: loading,
    };

    return (
        <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
            <FormCondition formItemLayouts={{
                labelCol: {

                },
                wrapperCol: {

                },
            }} form={form} formItems={formItems}></FormCondition>
        </Modal >
    );
};

export default connect(({ order, loading }) => ({
    loading: loading.effects['answering/fakeChatUserQa'],
}))(editModal);
;
